t1=30*3.14/180;
t2=60*3.14/180;
t3=0;
t4=45*3.14/180;
t5=t4;
t6=t4;
a2=90;d3=30;d4=60;a3=15;
c1=cos(t1);c2=cos(t2);c3=cos(t3);c4=cos(t4);c5=cos(t5);c6=cos(t6);
s1=sin(t1);s2=sin(t2);s3=sin(t3);s4=sin(t4);s5=sin(t5);s6=sin(t6);
r11=c1*(cos(t2+t3)*(c4*c5*c6-s4*s5)-sin(t2+t3)*s5*c5)+s1*(s4*c5*c6+c4*s6);
r21=s1*(cos(t2+t3)*(c4*c5*c6-s4*s6)-sin(t2+t3)*s5*c6)-c1*(s4*c5*c6+c4*s6);
r31=-sin(t2+t3)*(c4*c5*c6-s4*s6)-cos(t2+t3)*s5*c6;
r12=c1*(cos(t2+t3)*(-c4*c5*s6-s4*c6)+sin(t2+t3)*s5*s6)+s1*(c4*c6-s4*c5*c6);
r22=s1*(cos(t2+t3)*(-c4*c5*s6-s4*c6)+sin(t2+t3)*s5*s6)-c1*(c4*c6-s4*c5*c6);
r32=-sin(t2+t3)*(c4*c5*c6-s4*s6)+cos(t2+t3)*s5*c6;
r13=-c1*(cos(t2+t3)*c4*s5+sin(t2+t3)*c5)-s1*s4*s5;
r23=-s1*(cos(t2+t3)*c4*s5+sin(t2+t3)*c5)+c1*s4*s5;
r33=sin(t2+t3)*c4*s5-cos(t2+t3)*c5;
px=c1*(a2*c2+a3*cos(t2+t3)-d4*sin(t2+t3))-d3*s1;
py=s1*(a2*c2+a3*cos(t2+t3)-d4*sin(t2+t3))-d3*c1;
pz=-a3*sin(t2+t3)-a2*s2-d4*cos(t2+t3);
T=[ r11 r12 r13 px;r21 r22 r23 py; r31 r32 r33 pz; 0 0 0 1]